﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using BLL;
using PaymentBLL;

/// <summary>
/// Summary description for WSAccount
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class WSAccount : System.Web.Services.WebService {

    public WSAccount () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public int UpdateStatus(int id, int status) {
        string function = HttpContext.Current.Request.Headers["Referer"].Substring(HttpContext.Current.Request.Headers["Referer"].LastIndexOf("/") + 1);
        int p = CtrAdmin.GetPermission(function);
        if ((p & (int)Config.EnumPermission.Edit) != (int)Config.EnumPermission.Edit)
            return -1;
        var ctr = new CtrAccount();       
        int result = ctr.UpdateAccountStatus(id,status);
        if (result > 0)
        {
            string des = "Cập nhật trạng thái Account: [id: " + id + ", status: " + status + "]";
            CtrLog.InsertLog(Config.LogActionConstants.Modify, des, function);
        }
        return result;
    }
    
}
